package com.aidong.util;

/**
 * Created by john on 16-11-2.
 */
import com.aidong.dao.wills.PssProductStockDao;
import com.aidong.model.wills.PssProductStock;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

@Repository
public class StockUtil {
    private static Logger log = Logger.getLogger(StockUtil.class);
    @Resource
    PssProductStockDao pssProductStockDao;

    public StockUtil() {
    }

    public boolean checkStock(String shopCode, String productCd, Double qty) {
        if(Double.compare(0.0D, qty.doubleValue()) == 0) {
            return true;
        } else {
            PssProductStock pssProductStock = this.pssProductStockDao.findProductStock(shopCode, productCd);
            return null != pssProductStock && Double.compare(pssProductStock.getQuantity().doubleValue(), qty.doubleValue()) >= 0;
        }
    }
}
